<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

<script>

    var msg = "D:/前端开发/JavaScript/Demo.html";


    //截取网页名称(包含扩展名)

    var start = msg.lastIndexOf("/");/* 获取最后一个/的位置 */

    var end = msg.length;

    var docName = msg.substring(start + 1, end)
    console.log(docName);


    //获取文件扩展名

    var extName = msg.split(".")[1];
    console.log(extName);


    var num1 = "12345nnnnn";

    console.log(Number(num1)); //A  Number()函数只能转换数字字符串，不能转换数字型字符串

    console.log(parseInt(num1)); //B  parseInt()函数可以转换数字字符串，也可以转换数字型字符串


    var num2 = "s123tring";

    console.log(Number(num2)); //C

    console.log(parseInt(num2)); //D

</script>
</body>
</html>